//package com.example.materialviewpagerdemo;
//
//import android.os.Build;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.annotation.RequiresApi;
//import android.support.v4.app.Fragment;
//import android.support.v4.widget.NestedScrollView;
//import android.support.v7.widget.CardView;
//import android.support.v7.widget.GridLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.util.Log;
//import android.view.Gravity;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.WindowManager;
//import android.widget.Button;
//import android.widget.ImageView;
//import android.widget.PopupWindow;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.example.materialviewpagerdemo.Presenter.CurrentDataController;
//import com.example.materialviewpagerdemo.bean.DataModel;
//import com.example.materialviewpagerdemo.bean.ListViewModel;
//import com.example.materialviewpagerdemo.bean.StaticData;
//import com.example.materialviewpagerdemo.data.CustomDatePicker;
//import com.example.materialviewpagerdemo.util.ChartUtil;
//import com.example.materialviewpagerdemo.util.LoadingUtil;
//import com.example.materialviewpagerdemo.view.CommonPopupWindow;
//import com.example.materialviewpagerdemo.view.PopRecyclerviewAdapter;
//import com.github.florent37.materialviewpager.MaterialViewPagerHelper;
//import com.github.mikephil.charting.charts.BarChart;
//import com.github.mikephil.charting.charts.LineChart;
//import com.github.mikephil.charting.data.BarEntry;
//import com.github.mikephil.charting.data.Entry;
//import com.zyao89.view.zloading.ZLoadingDialog;
//
//import org.greenrobot.eventbus.EventBus;
//import org.greenrobot.eventbus.Subscribe;
//import org.greenrobot.eventbus.ThreadMode;
//
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.Date;
//import java.util.List;
//import java.util.ListIterator;
//import java.util.Locale;
//
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import butterknife.Unbinder;
//import retrofit2.Call;
//import retrofit2.Callback;
//import retrofit2.Response;
//import retrofit2.Retrofit;
//import retrofit2.converter.gson.GsonConverterFactory;
//
//public class    DataAnalysisFragment extends Fragment {
//    @BindView(R.id.item_img)
//    ImageView itemImg;
//    @BindView(R.id.data_name)
//    TextView dataName;
//    @BindView(R.id.data_content)
//    TextView dataContent;
//    @BindView(R.id.card_view_part1)
//    CardView cardViewPart1;
//    @BindView(R.id.lineChart_name)
//    TextView lineChartName;
//    @BindView(R.id.lineChart)
//    LineChart lineChart;
//    @BindView(R.id.card_view)
//    CardView cardView;
//    @BindView(R.id.barchart_name)
//    TextView barchartName;
//    @BindView(R.id.chart_pm_one)
//    BarChart chartPmOne;
//    @BindView(R.id.card_view_barchart)
//    CardView cardViewBarchart;
//    Unbinder unbinder;
//    @BindView(R.id.materialScrollView)
//    NestedScrollView materialScrollView;
//    @BindView(R.id.currentDate_2)
//    TextView currentDate2;
//    @BindView(R.id.currentDate)
//    TextView currentDate;
//    @BindView(R.id.selectDate)
//    RelativeLayout selectDate;
//    @BindView(R.id.selectDate_2)
//    RelativeLayout selectDate2;
//    @BindView(R.id.card_view1)
//    CardView cardView1;
//    @BindView(R.id.bt_showall)
//    Button button1;
//    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//
//    protected CustomDatePicker customDatePicker1, customDatePicker2;
//
//    private ZLoadingDialog dialog;
//    ListViewModel listViewModel;
//    List<Entry> list = new ArrayList<>();
//    List<Entry> list1 = new ArrayList<>();
//    List<BarEntry> barlist = new ArrayList<>();
//    LoadingUtil loadingUtil;
//
//    //下面三行是在popupwindow中使用到的控件，在加载fragment的时候就对其进行初始化 initpop（）
//    private CommonPopupWindow popupWindow;
//    private View parentView;
//    private RecyclerView recyclerView;
//
//    private String start;
//    private String end;
//
//    //存储显示在pop中的数据
//    String[] popArray = new String[11];
//    //用于记录position，初始的时候默认是空气温度1，position是3
//    private static int positionDataAnalysis = 0;
//
//
//    @Nullable
//    @Override
//    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
//        View view = inflater.inflate(R.layout.analysis_layout, container, false);
//        unbinder = ButterKnife.bind(this, view);
//        return view;
//    }
//
//    @Override
//    public void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        EventBus.getDefault().register(this);
//    }
//
//    @Override
//    public void onDestroy() {
//        super.onDestroy();
//        EventBus.getDefault().unregister(this);
//    }
//
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//
//        dialog = new ZLoadingDialog(DataAnalysisFragment.this.getActivity());
//        MaterialViewPagerHelper.registerScrollView(getActivity(), materialScrollView);
//
//        initData();
//        initTimeListener();
//
//        //
//        firstInitData();
//        CilckThing("1");
//
//    }
//
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    public void CilckThing(String flag) {
//        button1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                // Toast.makeText(getActivity(), "请稍等！", Toast.LENGTH_LONG).show();
////                Date start1=new Date();
////                Date end1=new Date();
////                try {
////                     start1=sdf.parse(currentDate.getText().toString());
////                     end1=sdf.parse(currentDate2.getText().toString());
////                    Log.i("fyyy", "onClick: "+start1.toString()+"  "+end1.toString());
////                } catch (ParseException e) {
////                    Toast.makeText(getActivity(),"转换失败",Toast.LENGTH_LONG).show();
////                    e.printStackTrace();
////                }
//
//                //Toast.makeText(getActivity(), "加载成功", Toast.LENGTH_LONG).show();
//                if (timeJuege(getTimeString().get(0), getTimeString().get(1))) {
//                    //Log.i("fyyt", "点击操作: "+"返回值是空");
//                    if (getTimeString().get(0).equals(start) && getTimeString().get(1).equals(end)) {
//                        Toast.makeText(getActivity(), "时间段未改变", Toast.LENGTH_LONG).show();
//                    } else {
//                        Toast.makeText(getActivity(), "getTimeString().get(0)" + getTimeString().get(0), Toast.LENGTH_LONG).show();
//                        Toast.makeText(getActivity(), "start" + start, Toast.LENGTH_LONG).show();
//
//                        getDataList(currentDate.getText().toString(), currentDate2.getText().toString(), flag);
//                    }
//                }
//                //mvp模式，snackbar
//            }
//        });
//    }
//
//    private void initData() {
//
//        //时间选择器的相关
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
//        String now = sdf.format(new Date());
//        currentDate.setText(now.split(" ")[0]);
//        currentDate2.setText(now.split(" ")[0]);
//
//        customDatePicker1 = new CustomDatePicker(this.getContext(), new CustomDatePicker.ResultHandler() {
//            @Override
//            public void handle(String time) { // 回调接口，获得选中的时间
//                currentDate.setText(time.split(" ")[0]);
//            }
//        }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
//
//        customDatePicker2 = new CustomDatePicker(this.getContext(), new CustomDatePicker.ResultHandler() {
//            @Override
//            public void handle(String time) { // 回调接口，获得选中的时间
//                currentDate2.setText(time.split(" ")[0]);
//            }
//        }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
//        customDatePicker2.showSpecificTime(false); // 显示时和分
//        customDatePicker1.showSpecificTime(false);
//        customDatePicker2.setIsLoop(true); // 允许循环滚动
//
//
//    }
//
//    private void initTimeListener() {
//        selectDate.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                customDatePicker1.show(currentDate.getText().toString());
//                start = currentDate.getText().toString();
//            }
//        });
//
//        selectDate2.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                customDatePicker2.show(currentDate2.getText().toString());
//                end = currentDate2.getText().toString();
//            }
//        });
//    }
//
//    public List<String> getTimeString() {
//        List<String> result = new ArrayList<>();
//        result.add(currentDate.getText().toString());
//        result.add(currentDate2.getText().toString());
//        return result;
//    }
//
//    public boolean timeJuege(String smallTime, String bigTime) {
//        try {
//
//            if (!DateInt.judgeStartTime(smallTime)) {
//                Toast.makeText(getActivity(), "开始时间是2018-8-24日，请重新选择", Toast.LENGTH_SHORT).show();
//                return false;
//            }
//
//            int timeLength = DateInt.timeLengthJudge(smallTime, bigTime);
//
//            if (timeLength > 30) {
//                Toast.makeText(getActivity(), "时间间隔最大30天，请重新选择", Toast.LENGTH_SHORT).show();
//                return false;
//            }
//
//            if (timeLength <= 0) {
//                Toast.makeText(getActivity(), "时间间隔最小为1天，请重新选择", Toast.LENGTH_SHORT).show();
//                return false;
//            }
//
//
//            return true;
//
//
//        } catch (ParseException e) {
//            Toast.makeText(getActivity(), "请重新选择", Toast.LENGTH_SHORT).show();
//            timeRewrite();
//            return false;
//        }
//    }
//
//    public void timeRewrite() {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
//        String now = sdf.format(new Date());
//        currentDate.setText(now.split(" ")[0]);
//        currentDate2.setText(now.split(" ")[0]);
//    }
//
//    public void firstInitData() {
//        //第一次将顶部的cardView初始化
//        listViewModel = new ListViewModel();
//        listViewModel.setDataName("空气温度");
//        listViewModel.setImgId(R.drawable.ic_airtem);
//
//        //设置pop显示的数组
//        popArray = this.getActivity().getResources().getStringArray(R.array.dataTypeName);
//        //初始化Popupwindow
//        initPop();
//        //设置cardview的点击事件
//        cardViewListenser();
//
//        //设置统计图的名字
//        setRepeatName("空气温度");
//
//        //显示正在加载
//        dialog = new ZLoadingDialog(getActivity());
//        loadingUtil = new LoadingUtil(dialog);
//        loadingUtil.showDialog();
//
//        //获得数据 并显示
//        getCurrentData("1");
//        getDataList(7, "1");
//
//    }
//
//    private void cardViewListenser() {
//        cardViewPart1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                popupWindow.getPopupWindow().setAnimationStyle(R.style.animAlpha);
//                popupWindow.showAtLocation(parentView, Gravity.CENTER, 0, 0);
//                WindowManager.LayoutParams layoutParams = DataAnalysisFragment.this.getActivity().getWindow().getAttributes();
//                layoutParams.alpha = 0.3f;
//                DataAnalysisFragment.this.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
//                DataAnalysisFragment.this.getActivity().getWindow().setAttributes(layoutParams);
//            }
//        });
//    }
//
//    //初始化pop以及显示在其上的recyclerview
//    public void initPop() {
////      用parentView=LayoutInflater.from(getContext()).inflate(R.layout.activity_main,null);或下面这行代码
////      都可以获得对应的view
//
//        parentView = getActivity().findViewById(R.id.drawer_layout);
//
//        popupWindow = new CommonPopupWindow(this.getActivity(), R.layout.text_popup_layout,
//                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
//            @Override
//            protected void initView() {
//                View view = getContentView();
////                recyclerView初始化
//                recyclerView = view.findViewById(R.id.recycler);
//                recyclerView.setLayoutManager(new GridLayoutManager(DataAnalysisFragment.this.getActivity(), 2));
//                PopRecyclerviewAdapter homeAdapter = new PopRecyclerviewAdapter(DataAnalysisFragment.this.getActivity(), popArray);
//                homeAdapter.setRecyclerViewListener(new PopRecyclerviewAdapter.RecyclerViewListener() {
//                    @Override
//                    public void onItemClick(View view, int position) {
//                        Log.i("xianshi", "onItemClick: " + position);
//                        positionDataAnalysis = position;
//                        setRepeatName(popArray[position]);
//                        popupWindow.getPopupWindow().dismiss();
//                        loadingUtil.showDialog();
//                        //清空list，barlist中的数据
//                        list.clear();
//                        barlist.clear();
//
//                        //获得数据 并显示
//                        getCurrentData("1");
//                        getDataList(7, "1");
//                    }
//                });
//                recyclerView.setAdapter(homeAdapter);
//            }
//
//            @Override
//            protected void initEvent() {
//
//            }
//
//            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
//            @Override
//            protected void initWindow() {
//                super.initWindow();
//                PopupWindow instance = getPopupWindow();
//                instance.setOnDismissListener(new PopupWindow.OnDismissListener() {
//                    @Override
//                    public void onDismiss() {
//                        WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
//                        lp.alpha = 1.0f;
//                        getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
//                        getActivity().getWindow().setAttributes(lp);
//                    }
//                });
//            }
//        };
//    }
//
//    @Override
//    public void onDestroyView() {
//        super.onDestroyView();
//        unbinder.unbind();
//    }
//
//    public static Fragment newInstance() {
//        return new DataAnalysisFragment();
//    }
//
//
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    public void getCurrentData(String flag) {
//        Retrofit retrofit = new Retrofit.Builder().baseUrl(StaticData.url)
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//        CurrentDataController currentDataController = retrofit.create(CurrentDataController.class);
//        Call<DataModel> currentDataCall = currentDataController.queryOne(Integer.parseInt(flag));
//        currentDataCall.enqueue(new Callback<DataModel>() {
//            @Override
//            public void onResponse(Call<DataModel> call, Response<DataModel> response) {
//                try {
//
//                    listViewModel.setDataContent(response.body().getAirTemp() + "℃");
//                    switch (positionDataAnalysis) {
//                        case 0:
//                            listViewModel.setDataName("空气温度");
//                            listViewModel.setImgId(R.drawable.ic_fengsu);
//                            listViewModel.setDataContent(response.body().getAirTemp() + "℃");
//                            break;
//                        case 1:
//                            listViewModel.setDataName("空气湿度");
//                            listViewModel.setImgId(R.drawable.ic_fengxiang);
//                            listViewModel.setDataContent(response.body().getAirHumi() + "%");
//                            break;
//                        case 2:
//                            listViewModel.setDataName("风速");
//                            listViewModel.setImgId(R.drawable.ic_sunshine);
//                            listViewModel.setDataContent(response.body().getFengsu() + "KM/s");
//                            break;
//
//                        case 3:
//                            listViewModel.setDataName("风向");
//                            listViewModel.setImgId(R.drawable.ic_airhum);
//                            listViewModel.setDataContent(response.body().getFengxiang() + "°");
//                            break;
//                        case 4:
//                            listViewModel.setDataName("光照强度");
//                            listViewModel.setImgId(R.drawable.ic_soilhum);
//                            listViewModel.setDataContent(response.body().getSunLight() + "kLux");
//                            break;
//                        case 5:
//                            listViewModel.setDataName("土壤湿度-1");
//                            listViewModel.setImgId(R.drawable.ic_soilsalt);
//                            listViewModel.setDataContent(response.body().getSoilHumi1() + "%");
//                            break;
//                        case 6:
//                            listViewModel.setDataName("土壤电导率-1");
//                            listViewModel.setImgId(R.drawable.ic_soiltem);
//                            listViewModel.setDataContent(response.body().getSoilSalt1() + "dS/m");
//                            break;
//                        case 7:
//                            listViewModel.setDataName("土壤温度-1");
//                            listViewModel.setImgId(R.drawable.ic_airtem);
//                            listViewModel.setDataContent(response.body().getSoilTemp1() + "℃");
//                            break;
//                        case 8:
//                            listViewModel.setDataName("土壤湿度-2");
//                            listViewModel.setImgId(R.drawable.ic_airhum);
//                            listViewModel.setDataContent(response.body().getSoilHumi2() + "%");
//                            break;
//                        case 9:
//                            listViewModel.setDataName("土壤电导率-2");
//                            listViewModel.setImgId(R.drawable.ic_airhum);
//                            listViewModel.setDataContent(response.body().getSoilSalt2() + "dS/m");
//                            break;
//                        case 10:
//                                listViewModel.setDataName("土壤温度-2");
//                                listViewModel.setImgId(R.drawable.ic_airhum);
//                                listViewModel.setDataContent(response.body().getSoilTemp2() + "℃");
//                            break;
//                    }
//                } catch (NullPointerException e) {
//                    listViewModel.setDataContent("");
//                    Toast.makeText(DataAnalysisFragment.this.getActivity(), "数据获取失败,请检查网络后重试", Toast.LENGTH_SHORT).show();
//                }
//
//                dataContent.setText(listViewModel.getDataContent());
//                dataName.setText(listViewModel.getDataName());
//                itemImg.setImageDrawable(getActivity().getDrawable(listViewModel.getImgId()));
//            }
//
//            @Override
//            public void onFailure(Call<DataModel> call, Throwable t) {
//                loadingUtil.cancleDialog();
//                Toast.makeText(DataAnalysisFragment.this.getActivity(), "连接超时", Toast.LENGTH_SHORT).show();
//            }
//        });
//    }
//
//
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    private void getDataList(int number, String flag) {
//        Retrofit retrofit = new Retrofit.Builder()
//                .addConverterFactory(GsonConverterFactory.create())
//                .baseUrl(StaticData.url)
//                .build();
//        CurrentDataController currentDataController = retrofit.create(CurrentDataController.class);
//        Call<List<DataModel>> call = currentDataController.query(number, Integer.parseInt(flag));
//        call.enqueue(new Callback<List<DataModel>>() {
//            @Override
//            public void onResponse(Call<List<DataModel>> call, Response<List<DataModel>> response) {
//                if (response.body() != null) {
//                    ListIterator<DataModel> listIterator = null;
//                    try {
//                        listIterator = response.body().listIterator();
//                    } catch (NullPointerException e) {
//                        return;
//                    }
//                    int i = 0;
//                    while (listIterator.hasNext()) {
//
//                        i++;
//                        DataModel currentData = listIterator.next();
//                        addDataList(currentData, i);
//                    }
//
//                    Collections.reverse(list);
//                    Collections.reverse(barlist);
//                    ChartUtil.setChartData(lineChart, list);
//                    ChartUtil.setBarChartData(chartPmOne, barlist);
//                    //刷新数据,解决数据更新后界面不会自动刷新的问题，此处因为时间问题，比较匆忙，可以重构，改善代码结构
//                    lineChart.notifyDataSetChanged();
//                    chartPmOne.notifyDataSetChanged();
//                    lineChart.invalidate();
//                    chartPmOne.invalidate();
//                    //取消动画
//                    loadingUtil.cancleDialog();
//                }
//            }
//
//            @Override
//            public void onFailure(Call<List<DataModel>> call, Throwable t) {
//                loadingUtil.cancleDialog();
//                System.out.println("失败");
//            }
//        });
//    }
//
//
//    public void addDataList(DataModel currentData, int i) {
//        Entry entry = null;
//        BarEntry barEntry = null;
//        i = 10 - i;
//        //此处受到position的影响，position期初默认3，后来随着点击事件改变
//        switch (positionDataAnalysis) {
//            case 0:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getAirTemp()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getAirTemp()), ChartUtil.praseData(currentData.getDatetime()));
//                break;
//            case 1:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getAirHumi()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getAirHumi()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 2:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getFengsu()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getFengsu()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//
//            case 3:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getFengxiang()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getFengxiang()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 4:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSunLight()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSunLight()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 5:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSoilHumi1()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSoilHumi1()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 6:
//
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSoilSalt1()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSoilSalt1()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 7:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSoilTemp1()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSoilTemp1()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 8:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSoilHumi2()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSoilHumi2()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//
//            case 9:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSoilSalt2()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSoilSalt2()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//            case 10:
//                entry = new Entry(i, ChartUtil.toFloat(currentData.getSoilTemp2()), ChartUtil.praseData(currentData.getDatetime()));
//                barEntry = new BarEntry(i, ChartUtil.toFloat(currentData.getSoilTemp2()), ChartUtil.praseData(currentData.getDatetime()));
//
//                break;
//        }
//        list.add(entry);
//        barlist.add(barEntry);
//    }
//
//
//    public void setRepeatName(String name) {
//        lineChartName.setText(name + "-折线图");
//        barchartName.setText(name + "-柱状图");
//    }
//
//
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    private void getDataList(String start, String end, String flag) {
//        Retrofit retrofit = new Retrofit.Builder()
//                .addConverterFactory(GsonConverterFactory.create())
//                .baseUrl(StaticData.url)
//                .build();
//        Log.i("fyyt", "onResponse: " + "返回值是空1");
//        CurrentDataController currentDataController = retrofit.create(CurrentDataController.class);
//        Call<List<DataModel>> call = currentDataController.queryable(start, end, Integer.parseInt(flag));
//        Log.i("fyyt", "onResponse: " + "返回值是空2");
//        call.enqueue(new Callback<List<DataModel>>() {
//            @Override
//            public void onResponse(Call<List<DataModel>> call, Response<List<DataModel>> response) {
//                if (response.body() != null) {
//                    ListIterator<DataModel> listIterator = null;
//                    try {
//                        listIterator = response.body().listIterator();
//                        Log.i("fyyt", "onResponse: " + "返回值是空4");
//                    } catch (Exception e) {
//                        Log.i("fyyt", "onResponse: " + "返回值是空3" + e.getMessage());
//                        return;
//                    }
//                    int i = 0;
//                    while (listIterator.hasNext()) {
//
//                        i++;
//                        DataModel currentData = listIterator.next();
//                        addDataList(currentData, i);
//                    }
//
//                    Collections.reverse(list);
//                    Collections.reverse(barlist);
//                    ChartUtil.setChartData(lineChart, list);
//                    ChartUtil.setBarChartData(chartPmOne, barlist);
//                    //刷新数据,解决数据更新后界面不会自动刷新的问题，此处因为时间问题，比较匆忙，可以重构，改善代码结构
//                    lineChart.notifyDataSetChanged();
//                    chartPmOne.notifyDataSetChanged();
//                    lineChart.invalidate();
//                    chartPmOne.invalidate();
//                    //取消动画
//                    loadingUtil.cancleDialog();
//                    Log.i("fyyt", "onResponse: " + list.size() + "  " + barlist.size());
//                } else {
//
//                    Toast.makeText(getActivity(), "加载失败", Toast.LENGTH_LONG).show();
//                    Log.i("fyyt", "onResponse: " + "返回值是空");
//                }
//            }
//
//            @Override
//            public void onFailure(Call<List<DataModel>> call, Throwable t) {
//                loadingUtil.cancleDialog();
//                System.out.println("失败");
//            }
//        });
//    }
//}
